function abcd(sql, params, callback) {
    const mysql = require('mysql');
    const conn = mysql.createConnection({
        host: 'localhost',
        user: 'root',
        password: '12345678',
        database: 'hahaha'
    });
    conn.connect();

    // 完成增删改查
    conn.query(sql, params, callback);

    conn.end();
}

// 导出
module.exports = abcd;

// abcd('select * from student where id>?', 4, (err, result) => {
//     if (err) return console.log(err);
//     console.log(result);
// });

// abcd('select * from student', null, (err, result) => {
//     console.log(result);
// });

// abcd('insert into student set ?', {name: '王五', age: 20}, (err, result) => {
//     if (err || result.affectedRows <= 0) {
//         console.log(err);
//         console.log('添加失败');
//     } else {
//         console.log('添加成功');
//     }
// });